package com.hmall.search.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hmall.api.item.dto.ItemDTO;
import com.hmall.common.domain.PageDTO;

import com.hmall.search.domain.po.ItemDoc;
import com.hmall.search.domain.query.ItemPageQuery;
import com.hmall.search.service.ISearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author Administrator
 */
@Api(tags = "搜索相关接口")
@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ISearchService searchService;

    @ApiOperation("搜索商品")
    @GetMapping("/list")
    public PageDTO<ItemDoc> search(ItemPageQuery query) throws IOException {
        PageDTO<ItemDoc> result = searchService.searchItems(query);
        return result;
    }
}
